<template>
  <div>
    <input v-model="username" placeholder="Username" />
    <input v-model="password" type="password" placeholder="Password" />
    <button @click="login">Login</button>
  </div>
  <!-- <SumLoading></SumLoading> -->
</template>

<script lang="ts" setup>
import { defineComponent, onMounted, ref } from 'vue';
import { useStore } from 'vuex';
import wallet from '../chain/wallet';
// import SumLoading from '../components/SumLoading.vue';

const store = useStore();
const username = ref('');
const password = ref('');

const login = () => {
  // if (username.value && password.value) {
  console.log(store.commit);
  
    store.dispatch('user/login', { username: 'xxxx', password: 111 });
    // store.dispatch('user/login', { username: username.value, password: password.value });
  // }
}


//链接Phantom钱包
const walletStandardFun = async () => {

  try {
    wallet.setCurrentWallet('solana'); 
    await wallet.connect(); 
    if (wallet.connected) {
      localStorage.setItem('wallet', 'solana');
      console.log('connected', (wallet.publicKey as any).toBase58());
      localStorage.setItem("ISLOGININ", 'true');
    } else {
      localStorage.removeItem('wallet');
      localStorage.setItem("ISLOGININ", 'false');
    };
  } catch (error) {
    console.log(error);

  }
}
onMounted(() => {
  login()
  walletStandardFun();
  // console.log(1111);
})



</script>